Learning Objectives

After completing this lesson, you’ll be able to:

Introduction

In this course, you'll learn about transformers you can use for spatial joining, filtering, and analysis. These transformers will help you get more value from your spatial data by combining them and conducting queries that combine multiple spatial datasets.

What Is Spatial Joining and Filtering?

Spatial joining is a procedure that combines information between two datasets based on their spatial location. You might be familiar with key-based attribute joins, which join two tables based on a shared attribute. Spatial joins are similar, except instead of using an attribute value as the shared key, they use spatial location.

For example, you might read one dataset of transit stations and one dataset of postcode boundaries. You want to add an attribute to the transit stations that records their postcode. You could use the PointOnAreaOverlayer to join the postcode attributes to the stations based on which postcode they overlay. Now, you have a stream of station features that contain the postcode attribute.

Note

FME can also do key-based attribute joins. See the course Join Tables.

Spatial filtering is a procedure that separates features based on their spatial location. In FME, this filtering lets you create multiple data streams and do what you wish with each separate stream.

For example, you might read one dataset of transit stations and one dataset of postcode boundaries. You want to filter your data to select transit stations within a single postcode. You could use the SpatialFilter transformer to produce a data stream containing only those features.

In FME, filtering usually refers to creating multiple streams, but the line between filtering and joining is unclear. You will often need to join before you can filter, or you might join after you filter. It all depends on your desired outcome. Combining FME's filtering and joining transformers will let you get your data in precisely the desired shape.

Spatial Joining and Filtering Transformers

Multiple transformers can join data by spatial relationship. Which transformer you use depends on the spatial relationship to be tested and your exact join requirements. The following are some of the key transformers.

Note

Like the key-based joining transformers, there is a flowchart to help you choose a spatial join transformer. See the Merging or Joining Spatial Data article.

Overlayers

There are several different "overlayer" transformers, each handling a different form of overlaying.

For example, the PointOnAreaOverlayer performs a spatial join on points that fall inside area (polygon) features. This operation is sometimes called a "Point in Polygon" overlay. In terms of set theory, overlayers look for the intersection of two streams of spatial features. They return both streams in full but add intersection information as attributes.

As the help explains, "Each point receives the attributes of the area(s) it is contained in, and each containing area receives the attributes of each point it contains."

Merge Attributes parameter location in Overlayer transformers

Here, the TransitStation features are provided with a postal code (CFSAUID) that depends on which PostcodeBoundary polygon they fall inside.

The "_overlaps" attribute is another valuable outcome of this transformer. It tells us how many polygons each station fell inside; in this case, overlapping postal codes might be spotted by a station having more than one overlap.

Conversely, the Area output would have an "_overlaps" attribute that would tell us how many stations fell inside each postal code.

Note

Before FME 2020.1, Overlayer transformers automatically merged all attributes. The new default behavior is not to merge attributes, but this parameter can be enabled under Attribute Accumulation > Merge Attributes.

Note

The Overlayer transformers only work with vector data. You can accomplish a similar analysis with raster data using transformers like the PointOnRasterValueExtractor.

NeighborFinder

The NeighborFinder transformer carries out a spatial join based on a proximity relationship. Here, the NeighborFinder is being used to identify the closest fire hall to each transit station:

NeighborFinder parameters

Optionally, the fire hall number, name, address, and phone number attributes are merged onto each Facility feature along with many valuable attributes (not all shown), recording the X/Y coordinate, direction, and distance of the closest fire hall.

The parameters of the NeighborFinder include the ability to specify a maximum distance for the relationship or the maximum number of neighbors to find.

FeatureReader

The FeatureReader is the spatial equivalent of the DatabaseJoiner transformer. It reads from an external dataset and forms a match based on a spatial relationship between the initiating feature and features in that dataset.

One difference is that the output is not the original feature but the queried feature; hence the name FeatureReader:

FeatureReader Spatial Filter and attribute accumulation parameters

For example, the FeatureReader is used to carry out the same overlay of transit stations and postal codes. The PostcodeBoundaries features are read into the workspace and used to query TransitStations (a table in a Geodatabase) spatially. The stations are retrieved with the attributes of the postcode feature they fall inside.

This also acts as a filter, as stations are not outputted unless they fall inside the postcode boundary.

SpatialFilter

As its name suggests, the SpatialFilter filters data according to a spatial relationship. However, it also merges attributes from one feature to another, which makes it a type of spatial join.

SpatialFilter example

The critical part is connecting both Passed and Failed output ports unless you also want to filter the data.

Note

Learn more in our  Data Integration Basics: Merging & Joining Data webinar.